package com.rainng.coursesystem.model.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.util.Date;

@TableName("event")
@Data
public class EventEntity {
    public static final String ID = "event_id";
    public static final String LEADER_ID = "event_leader_id";
    public static final String NAME = "event_name";
    public static final String NUMBER = "event_number";
    public static final String TIME = "event_time";
    public static final String LOCATION = "event_location";
    public static final String RATE= "event_rate";
    public static final String TYPE = "event_type";
    public static final String SELECTED_COUNT = "event_selected_count";
    public static final String MAX_SIZE = "event_max_size";
    public static final String START_DATE = "event_start_date";
    public static final String END_LOCATION = "event_end_location";

    @NotNull
    @TableId(value = ID, type = IdType.AUTO)
    private Integer id;

    @NotNull(message = "必须选择团长")
    @TableField(LEADER_ID)
    private Integer leaderId;

    @NotBlank(message = "项目名不能为空")
    @TableField(NAME)
    private String name;

    @NotNull
    @Range(min = 10, max = 50, message = "团成员最大人数必须在10_50之间")
    @TableField(NUMBER)
    private Integer number;

    @Pattern(regexp = "[1-7]-[1-9]-[1-4]", message = "项目最长时间为4小时")
    @TableField(TIME)
    private String time;

    @NotBlank(message = "出发地点不能为空")
    @TableField(LOCATION)
    private String location;

    @NotNull
    @Range(min = 1, max = 5, message = "推荐指数必须在1-5之间")
    @TableField(RATE)
    private Integer rate;

    @TableField(SELECTED_COUNT)
    private Integer selectedCount;

    @NotNull
    @Range(min = 0, message = "容量不能为负数")
    @TableField(MAX_SIZE)
    private Integer maxSize;

    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm")
    @TableField(value = START_DATE, updateStrategy = FieldStrategy.IGNORED)
    private Date startDate;

    @TableField(value = END_LOCATION, updateStrategy = FieldStrategy.IGNORED)
    private String endLocation;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Integer getLeaderId() {
		return leaderId;
	}

	public void setLeaderId(Integer leaderId) {
		this.leaderId = leaderId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getNumber() {
		return number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

	public String getTime() {
		return time;
	}

	public void setTime(String time) {
		this.time = time;
	}

	public String getLocation() {
		return location;
	}

	public void setLocation(String location) {
		this.location = location;
	}

	public Integer getRate() {
		return rate;
	}

	public void setRate(Integer rate) {
		this.rate = rate;
	}

	public Integer getSelectedCount() {
		return selectedCount;
	}

	public void setSelectedCount(Integer selectedCount) {
		this.selectedCount = selectedCount;
	}

	public Integer getMaxSize() {
		return maxSize;
	}

	public void setMaxSize(Integer maxSize) {
		this.maxSize = maxSize;
	}

	public Date getStartDate() {
		return startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}

	public String getEndLocation() { return endLocation; }

	public void setEndLocation(String endLocation) {
		this.endLocation = endLocation;
	}


	public static String getType() {
		return TYPE;
	}

    
    
}
